//
//  RootViewController.m
//  helloword
//
//  Created by chen on 17/2/15.
//  Copyright © 2017年 chen. All rights reserved.
//

#import "RootViewController.h"

@interface RootViewController ()<UITextFieldDelegate,UITextViewDelegate>
@property (strong, nonatomic) IBOutlet UILabel *label;

@property (strong, nonatomic) IBOutlet UIButton *button;
@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [_button addTarget:self action:@selector(onClick) forControlEvents:UIControlEventTouchUpInside];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(registerCompletion:) name:@"RegisterCompletionNotification" object:nil];
    
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)onClick:(id)sender {
    NSLog(@"OK Button onClick");
    _label.text = @"chenbinghui";
    NSDictionary *dict =[NSDictionary dictionaryWithObject:self.label.text forKey:@"username"];
    [[NSNotificationCenter defaultCenter]postNotificationName:@"RegisterCompletionNotification" object:nil userInfo:dict];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    // Dispose of any resources that can be recreated.
}
-(void)registerCompletion:(NSNotification *)notification{
    NSDictionary *theDate = [notification userInfo];
    NSString *username = [theDate objectForKey:@"username"];
}
- (void)onClick{
    NSLog(@"sssssssss");
}


#pragma mark -- 实现UITextFieldDelegate委托协议方法
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    NSLog(@"TextField获取焦点，点击return键");
    return TRUE;
}

#pragma mark -- 实现UITextViewDelegate委托协议方法
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    if ([text isEqualToString:@"\n"]) {
        NSLog(@"TextView获取焦点，点击return键");
        return FALSE;
    }
    return TRUE;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
